package com.ruoyi.activiti.listener;

import com.ruoyi.caigou.api.RemoteBuyBackReqService;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.utils.SpringUtils;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.system.api.domain.caigou.BuyBackReq;
import com.ruoyi.xiaoshou.api.RemoteSaleBackRequestService;
import com.ruoyi.xiaoshou.domain.SaleBackRequest;
import lombok.extern.slf4j.Slf4j;
import org.activiti.engine.delegate.DelegateExecution;
import org.activiti.engine.delegate.ExecutionListener;

/**
 * @author 罗梦杰
 * date 2024/10/31 12:51
 * @version 1.0
 */
@Slf4j
public class SaleBackRequestListener implements ExecutionListener {
    @Override
    public void notify(DelegateExecution delegateExecution) {
        SaleBackRequest saleBackRequest = new SaleBackRequest();
        saleBackRequest.setSaleBackRequestCode(delegateExecution.getProcessInstanceBusinessKey());
        saleBackRequest.setStatus((Integer) delegateExecution.getVariable("approvalResult"));
        //TODO 审核意见
        log.info("SaleBackRequestListener notify saleBackRequest:{} ", saleBackRequest);
        //TODO 调用采购退货申请修改接口
        R<String> request = SpringUtils.getBean(RemoteSaleBackRequestService.class).updSaleBackRequestByCode(saleBackRequest);
        log.info("request:{}", request);
    }
}
